let obj = {
  name: "tom",
  virtualY: {
    isVirtualWrapper: true,
    companyName: "擎创科技",
    location: "上海",
  },
  virtualA: {
    isVirtualWrapper: true,
    virtualB: { isVirtualWrapper: true, address: "孵化园C区" },
    realProp: { isVirtualWrapper: false, title: "真实属性" },
    virtualA: {
      isVirtualWrapper: true,
      virtualB: { isVirtualWrapper: true, address2: "孵化园C区2" },
      realProp: { isVirtualWrapper: false, title2: "真实属性2" },
    },
  },
  isVirtualWrapper: true,
};
/**
 * @param {Object} data  需要剔除虚拟层的源数据
 * @returns {Object}     剔除虚拟层后的数据
 */
function deleteVirtualWrapper(data) {
  //your code
  const map = {};
  // 遍历对象属性
  const getObject = (obj) => {
    if (typeof obj === "object") {
      const keys = Object.keys(obj);
      keys.forEach((key) => {
        if (key !== "isVirtualWrapper") {
          if (obj[key].isVirtualWrapper) {
            // 如果是虚拟包裹层
            const temp = obj[key];
            delete obj[key];
            getObject(temp);
          } else {
            // 如果不是虚拟包裹层
            map[key] = obj[key];
          }
        }
      });
    }
  };
  getObject(data);
  return map;
}
console.log("🚀  deleteVirtualWrapper 测试结果:", deleteVirtualWrapper(obj));
